package com.example.myandroidapp

import android.os.Bundle
import android.widget.ImageView
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import com.bumptech.glide.Glide

class Component : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        enableEdgeToEdge()
        setContentView(R.layout.activity_component)
        ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main)) { v, insets ->
            val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
            v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom)
            insets
        }

        //根据id获取图片组件的对象，并设置在线图片
        val img = findViewById<ImageView>(R.id.img3)
        Glide.with(this)
            .load("https://p0.itc.cn/q_70/images03/20230802/c8cc7984ea0d48d3a05b5fb7ae0a1d7a.gif")
            .placeholder(R.drawable.ic_launcher_foreground) // 设置加载中的占位图
            .into(img)

    }
}